package com.tvunetworks.center.device.config.web;

import com.tvunetworks.center.device.interceptor.OpenApiInterceptor;
import com.tvunetworks.center.device.resolver.LoginedArgumentResolver;
import com.tvunetworks.center.device.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.List;


/**
 * @author lebron
 * @ClassName: MyMybatisProperties
 * @Description: Mybatis参数
 */
@Configuration
public class WebConfiguration extends WebMvcConfigurationSupport {
    
	@Autowired
	private RedisUtil redisUtil;

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        super.addArgumentResolvers(argumentResolvers);
        argumentResolvers.add(new LoginedArgumentResolver(redisUtil));
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(openApiInterceptor());
        super.addInterceptors(registry);
    }

    /**
     *
     * @return OpenApiInterceptor
     */
    @Bean
    public OpenApiInterceptor openApiInterceptor() {
        return new OpenApiInterceptor();
    }

}
